import Vue from 'vue'
import VueRouter from 'vue-router'

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch((err) => err);
};


const Login = () => import("@/views/Login");
const Home = () => import("@/components/Layout/home")
const Welcome = () => import("@/views/home/welcome")

Vue.use(VueRouter)

const routes = [
    {
        path: "/",
        redirect: "/login",
    },
    {
        path: "/login",
        name: "Login",
        component: Login,
    },
    {
        path: "/home",
        name: "首页",
        component: Home,
        redirect: "/welcome",
        children: [
            {
                path: "/welcome",
                name: "首页",
                component: Welcome,
            },
        ],
    },
]

const router = new VueRouter({
    mode: "history",
    routes
})

router.cleared = function () {
    router.matcher = new VueRouter().matcher;
}

export default router;
